
// Texture
sampler TextureSampler : register(s0);
sampler NormalSampler  : register(s1);

// Extern parameters
float offsetX;
float offsetY;

// Main method
float4 main(float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
	float2 NormalTexCoord = texCoord;
	NormalTexCoord.x += offsetX;
	if (NormalTexCoord.x > 1.0f)
		NormalTexCoord.x -= 1.0f;
	NormalTexCoord.y += offsetY;
	if (NormalTexCoord.y > 1.0f)
		NormalTexCoord.y -= 1.0f;

	float2 RealCoord = (float3(texCoord, 0) + tex2D(NormalSampler, NormalTexCoord).xyz / 80.0f).xy;
    return tex2D(TextureSampler, RealCoord) * color;
}

// Techniques
technique Test
{
    pass Pass1
    {
        PixelShader = compile ps_2_0 main();
    }
}
